package cn.lili.controller;

import cn.lili.common.vo.ResponseBean;
import cn.lili.modules.dto.CommentVideoDTO;
import cn.lili.modules.dto.ShareDTO;
import cn.lili.modules.entity.AppUser;
import cn.lili.modules.service.AppGiveService;
import cn.lili.modules.service.AppReadService;
import cn.lili.modules.service.AppUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author:xiangqian
 * @date: 2024/3/11 19:45
 */
@RestController
@AllArgsConstructor
@Api(tags = "未读消息管理")
@RequestMapping("/videos")
public class AppReadController {

    private AppReadService appReadService;
    private AppUserService appUserService;

    @ApiModelProperty(value = "获取未读消息数量")
    @GetMapping("/read/getReadAll")
    public ResponseBean getReadAll(String token) {
        AppUser appUser = appUserService.getAppUserByToken(token);
        return ResponseBean.success(appReadService.getAppReadOnSave(appUser.getOpenid()));
    }

    @ApiModelProperty(value = "清除未读消息数量接口")
    @GetMapping("/read/clearRead")
    public ResponseBean clearRead(String token, Integer type) {
        AppUser appUser = appUserService.getAppUserByToken(token);
        return appReadService.updateAppRead(appUser.getOpenid(), type, 0);
    }
}